package com.woniu.liuzhougov.itemAndTask.controller;

import com.woniu.liuzhougov.authorityControl.pojo.User;
import com.woniu.liuzhougov.itemAndTask.pojo.Supervision;
import com.woniu.liuzhougov.itemAndTask.service.SupervisionService;
import com.woniu.liuzhougov.itemAndTask.vo.LayUIResult;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author wyz02
 * @version 1.0
 * @ClassName SupervisionController
 * @Description: 督办单控制器
 * @date 2019/4/29 11:12
 */
@RequestMapping("supervision")
@Controller
public class SupervisionController {
    @Autowired
    private SupervisionService supervisionService;

    /*
    **
     * @Author Wuyuzhong
     * @Description 查询当前用户下发的督办单
     * @Date 2019/4/29 11:19
     * @Param []
     * @return com.woniu.liuzhougov.itemAndTask.vo.LayUIResult
     **/
    @RequestMapping("/given")
    @ResponseBody
    public LayUIResult getMyGiven(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();   //获取登录信息
        List<Supervision> supervisions=supervisionService.searchByFounder(user.getUserId());
        LayUIResult result = new LayUIResult(supervisions);

        

        return result;
    }

    /*
    **
     * @Author Wuyuzhong
     * @Description 查询当前用户收到的督办单
     * @Date 2019/4/29 11:19
     * @Param []
     * @return com.woniu.liuzhougov.itemAndTask.vo.LayUIResult
     **/
    @RequestMapping("/recieve")
    @ResponseBody
    public LayUIResult getMyRecieve(){
        User user = (User) SecurityUtils.getSubject().getPrincipal();   //获取登录信息
        List<Supervision> supervisions=supervisionService.searchByReciever(user.getUserId());
        LayUIResult result = new LayUIResult(supervisions);
        return result;
    }
}
